package com.bridgeintelligent.tag.engine.mvc.strategy;

import com.bridgeintelligent.tag.engine.es.model.AnalysisAggregationModel;
import com.bridgeintelligent.tag.engine.mvc.service.IGroupService;


public enum AnalysisStrategy {

    X_NUMBER_DEFAULT_Y_NUMBER_DEFAULT(1) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model, IGroupService groupService) {
            return new XNumberDefaultYNumberDefault(model,groupService);
        }
    },

    X_NUMBER_DEFAULT_Y_NUMBER_RANGE(2) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model, IGroupService groupService) {
            return new XNumberDefaultYNumberRange(model,groupService);
        }
    },

    X_NUMBER_RANGE_Y_NUMBER_DEFAULT(3) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XNumberRangeYNumberDefault(model,groupService);
        }
    },

    X_NUMBER_RANGE_Y_NUMBER_RANGE(4) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XNumberRangeYNumberRange(model,groupService);
        }
    },

    X_NUMBER_DEFAULT_Y_DATE_DEFAULT(5) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XNumberDefaultYDateDefault(model,groupService);
        }
    },

    X_NUMBER_DEFAULT_Y_DATE_RANGE(6) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XNumberDefaultYDateRange(model,groupService);
        }
    },

    X_NUMBER_RANGE_Y_DATE_DEFAULT(7) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XNumberRangeYDateDefault(model,groupService);
        }
    },

    X_NUMBER_RANGE_Y_DATE_RANGE(8) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XNumberRangeYDateRange(model,groupService);
        }
    },

    X_NUMBER_DEFAULT_Y_TERM_DEFAULT(9) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model, IGroupService groupService) {
            return new XNumberDefaultYTermDefault(model,groupService);
        }
    },

    X_NUMBER_RANGE_Y_TERM_DEFAULT(10) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model, IGroupService groupService) {
            return new XNumberRangeYTermDefault(model,groupService);
        }
    },

    X_DATE_DEFAULT_Y_NUMBER_DEFAULT(11) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model, IGroupService groupService) {
            return new XDateDefaultYNumberDefault(model,groupService);
        }
    },


    X_DATE_DEFAULT_Y_NUMBER_RANGE(12) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XDateDefaultYNumberRange(model,groupService);
        }
    },

    X_DATE_RANGE_Y_NUMBER_DEFAULT(13) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model, IGroupService groupService) {
            return new XDateRangeYNumberDefault(model,groupService);
        }
    },

    X_DATE_RANGE_Y_NUMBER_RANGE(14) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XDateRangeYNumberRange(model,groupService);
        }
    },

    X_DATE_DEFAULT_Y_DATE_DEFAULT(15) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XDateDefaultYDateDefault(model,groupService);
        }
    },

    X_DATE_DEFAULT_Y_DATE_RANGE(16) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XDateDefaultYDateRange(model,groupService);
        }
    },

    X_DATE_RANGE_Y_DATE_DEFAULT(17) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XDateRangeYDateDefault(model,groupService);
        }
    },

    X_DATE_RANGE_Y_DATE_RANGE(18) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XDateRangeYDateRange(model,groupService);
        }
    },

    X_DATE_DEFAULT_Y_TERM_DEFAULT(19) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XDateDefaultYTermDefault(model,groupService);
        }
    },

    X_DATE_RANGE_Y_TERM_DEFAULT(20) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XDateRangeYTermDefault(model,groupService);
        }
    },

    X_TERM_DEFAULT_Y_TERM_DEFAULT(21) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XTermDefaultYTermDefault(model,groupService);
        }
    },

    X_TERM_DEFAULT_Y_NUMBER_DEFAULT(22) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XTermDefaultYNumberDefault(model,groupService);
        }
    },

    X_TERM_DEFAULT_Y_NUMBER_RANGE(23) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XTermDefaultYNumberRange(model,groupService);
        }
    },

    X_TERM_DEFAULT_Y_DATE_DEFAULT(24) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XTermDefaultYDateDefault(model,groupService);
        }
    },

    X_TERM_DEFAULT_Y_DATE_RANGE(25) {
        @Override
        public AbstractAnalysisTemple exec(AnalysisAggregationModel model,  IGroupService groupService) {
            return new XTermDefaultYDateRange(model,groupService);
        }
    };

    int type;

    AnalysisStrategy(int code) {
        this.type = code;
    }

    public static AbstractAnalysisTemple create(int type, AnalysisAggregationModel model,IGroupService groupService) {
        for (AnalysisStrategy analysisType : values()) {
            if (analysisType.type == type) {
                return analysisType.exec(model,groupService);
            }
        }
        return X_NUMBER_DEFAULT_Y_NUMBER_DEFAULT.exec(model,groupService);
    }

    public abstract AbstractAnalysisTemple exec(AnalysisAggregationModel model,IGroupService groupService);
}
